/*
 * 计算一元二次方程的根v2.0（4分）
 *
 * v1.0，见：02_week02/7_Solve_The_Equation_of_Two_Degree.c
 */

#include <stdio.h>
#include <math.h>

int main() {
	setbuf(stdout, NULL);

	float a, b, c;

	printf("Please enter the coefficients a,b,c:\n");
	scanf("%f,%f,%f", &a, &b, &c);

	if ((b * b - 4 * a * c) >= 0) {
		printf("x1=%7.4f, x2=%7.4f\n",
		 (-b + sqrt(b * b - 4 * a * c)) / (2 * a),
		 (-b - sqrt(b * b - 4 * a * c)) / (2 * a));
	} else {
		printf("error!\n");
		return -2;
	}

	if ((b * b - 4 * a * c) == 0) {
		return 1;
	}

	return 0;
}

// review: 此题由Online_Exercising - 02_week02 - 7引申
